```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Elasticsearch 倒排索引深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #2d3748;
        }
        .hero-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .first-letter:first-letter {
            font-size: 3.5rem;
            float: left;
            line-height: 1;
            margin-right: 0.75rem;
            margin-top: 0.25rem;
            color: #667eea;
            font-weight: 700;
        }
        .link-hover:hover {
            color: #667eea;
            transform: translateX(3px);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-bg text-white py-24 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Elasticsearch 倒排索引深度解析</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">揭秘分布式搜索引擎的核心数据结构</p>
            <div class="flex justify-center space-x-4">
                <a href="#what-is" class="px-6 py-3 bg-white text-indigo-700 font-medium rounded-lg hover:bg-opacity-90 transition duration-300 transform hover:scale-105">
                    <i class="fas fa-search mr-2"></i>了解倒排索引
                </a>
                <a href="#visualization" class="px-6 py-3 bg-indigo-900 bg-opacity-50 text-white font-medium rounded-lg hover:bg-opacity-70 transition duration-300 transform hover:scale-105">
                    <i class="fas fa-project-diagram mr-2"></i>可视化解析
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- What is Inverted Index -->
        <section id="what-is" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-search text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">什么是倒排索引？</h2>
            </div>
            
            <div class="first-letter bg-white p-8 rounded-xl shadow-md mb-8">
                <p><strong>倒排索引</strong>（Inverted Index）是一种将文档中的词（Token）与包含这些词的文档相对应的数据结构。倒排索引的名称来源于它与传统的"正向索引"相反。在正向索引中，每个文档都存储其所有词的列表；而在倒排索引中，每个词都存储其出现在哪些文档中的列表。</p>
                <p class="mt-4">简单来说，倒排索引类似于书的索引（Index），在书的末尾列出词汇和每个词汇出现的页码。在倒排索引中，我们列出所有词汇及其在文档集中的位置。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-md border-l-4 border-indigo-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-book mr-2 text-indigo-600"></i>正向索引
                    </h3>
                    <p>文档 → 词汇列表</p>
                    <p class="mt-2 text-gray-600">文档1: ["Elasticsearch", "是", "分布式", "搜索引擎"]</p>
                    <p class="text-gray-600">文档2: ["搜索引擎", "使用", "倒排索引"]</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md border-l-4 border-indigo-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-book-open mr-2 text-indigo-600"></i>倒排索引
                    </h3>
                    <p>词汇 → 文档列表</p>
                    <p class="mt-2 text-gray-600">"Elasticsearch": [文档1]</p>
                    <p class="text-gray-600">"搜索引擎": [文档1, 文档2]</p>
                    <p class="text-gray-600">"倒排索引": [文档2]</p>
                </div>
            </div>
        </section>

        <!-- Structure Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-sitemap text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">倒排索引的基本结构</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-6 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-bookmark"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">词典 (Dictionary)</h3>
                    <p class="text-gray-700">包含所有唯一词汇的集合。词典中每个词都是从所有文档的内容中提取的，并去掉了重复项。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-list-ol"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">倒排列表 (Posting List)</h3>
                    <p class="text-gray-700">每个词都有一个与之关联的倒排列表，包含所有出现了该词的文档的标识符（文档 ID）。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-table"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">倒排表 (Inverted Table)</h3>
                    <p class="text-gray-700">词典和倒排列表的组合，为每个词汇提供一个倒排列表，快速定位包含该词的所有文档。</p>
                </div>
            </div>
        </section>

        <!-- Construction Process -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-cogs text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">倒排索引的构建过程</h2>
            </div>

            <div class="relative">
                <!-- Timeline -->
                <div class="hidden sm:block absolute h-full w-1 bg-indigo-200 left-1/2 transform -translate-x-1/2"></div>
                
                <!-- Timeline steps -->
                <div class="mb-8 sm:mb-16">
                    <div class="flex flex-col sm:flex-row items-center">
                        <div class="flex-1 sm:pr-16 sm:text-right mb-4 sm:mb-0">
                            <h3 class="text-xl font-bold">1. 分词 (Tokenization)</h3>
                            <p class="text-gray-600">将文档内容分解成基本的词汇单元</p>
                        </div>
                        <div class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mx-auto sm:mx-0">
                            <span>1</span>
                        </div>
                        <div class="flex-1 sm:pl-16">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <p>"Elasticsearch 是一个分布式搜索引擎" →</p>
                                <p class="text-indigo-600 mt-1">[Elasticsearch, 是, 一个, 分布式, 搜索, 引擎]</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mb-8 sm:mb-16">
                    <div class="flex flex-col sm:flex-row items-center">
                        <div class="flex-1 sm:pr-16 sm:text-right mb-4 sm:mb-0">
                            <h3 class="text-xl font-bold">2. 去除停用词</h3>
                            <p class="text-gray-600">移除常见无意义的词</p>
                        </div>
                        <div class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mx-auto sm:mx-0">
                            <span>2</span>
                        </div>
                        <div class="flex-1 sm:pl-16">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <p>[Elasticsearch, 是, 一个, 分布式, 搜索, 引擎] →</p>
                                <p class="text-indigo-600 mt-1">[Elasticsearch, 分布式, 搜索, 引擎]</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mb-8 sm:mb-16">
                    <div class="flex flex-col sm:flex-row items-center">
                        <div class="flex-1 sm:pr-16 sm:text-right mb-4 sm:mb-0">
                            <h3 class="text-xl font-bold">3. 词干提取/词形还原</h3>
                            <p class="text-gray-600">将词汇简化为基本形式</p>
                        </div>
                        <div class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mx-auto sm:mx-0">
                            <span>3</span>
                        </div>
                        <div class="flex-1 sm:pl-16">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <p>"running" → "run", "better" → "good"</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mb-8 sm:mb-16">
                    <div class="flex flex-col sm:flex-row items-center">
                        <div class="flex-1 sm:pr-16 sm:text-right mb-4 sm:mb-0">
                            <h3 class="text-xl font-bold">4. 生成词典和倒排列表</h3>
                            <p class="text-gray-600">记录词汇出现的文档和位置</p>
                        </div>
                        <div class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mx-auto sm:mx-0">
                            <span>4</span>
                        </div>
                        <div class="flex-1 sm:pl-16">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <p class="text-indigo-600">"Elasticsearch": [文档1, 位置1]</p>
                                <p class="text-indigo-600">"引擎": [文档1, 位置6]</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mb-8">
                    <div class="flex flex-col sm:flex-row items-center">
                        <div class="flex-1 sm:pr-16 sm:text-right mb-4 sm:mb-0">
                            <h3 class="text-xl font-bold">5. 存储倒排索引</h3>
                            <p class="text-gray-600">压缩存储以提高效率</p>
                        </div>
                        <div class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mx-auto sm:mx-0">
                            <span>5</span>
                        </div>
                        <div class="flex-1 sm:pl-16">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <p>使用前缀压缩等技术优化存储空间</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visualization" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-project-diagram text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">倒排索引可视化解析</h2>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-md mb-8">
                <div class="mermaid">
                    graph TD
                        A[文档1: Elasticsearch 是一个分布式搜索引擎] --> B[分词]
                        B --> C1["Elasticsearch"]
                        B --> C2["是"]
                        B --> C3["一个"]
                        B --> C4["分布式"]
                        B --> C5["搜索"]
                        B --> C6["引擎"]
                        
                        C2 --> D[去除停用词]
                        C3 --> D
                        
                        C1 --> E[词典]
                        C4 --> E
                        C5 --> E
                        C6 --> E
                        
                        E --> F1["Elasticsearch: 文档1"]
                        E --> F2["分布式: 文档1"]
                        E --> F3["搜索: 文档1"]
                        E --> F4["引擎: 文档1"]
                        
                        G[文档2: 搜索引擎使用倒排索引] --> H[分词]
                        H --> I1["搜索"]
                        H --> I2["引擎"]
                        H --> I3["使用"]
                        H --> I4["倒排"]
                        H --> I5["索引"]
                        
                        I3 --> J[去除停用词]
                        
                        I1 --> K[词典]
                        I2 --> K
                        I4 --> K
                        I5 --> K
                        
                        K --> L1["搜索: 文档1, 文档2"]
                        K --> L2["引擎: 文档1, 文档2"]
                        K --> L3["倒排: 文档2"]
                        K --> L4["索引: 文档2"]
                </div>
            </div>
        </section>

        <!-- Applications Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-rocket text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">倒排索引在全文搜索中的应用</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover border-t-4 border-blue-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-bolt text-blue-500 mr-2"></i>快速匹配关键词
                    </h3>
                    <p>通过倒排索引，可以迅速找到包含特定关键词的所有文档。查询过程只需查找词典中的关键词，然后获取与之关联的倒排列表。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover border-t-4 border-green-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-code-branch text-green-500 mr-2"></i>布尔查询
                    </h3>
                    <p>倒排索引支持布尔操作，如 "AND", "OR", "NOT"。可以分别获取不同词的倒排列表，然后对列表进行交集、并集等运算。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover border-t-4 border-purple-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-quote-right text-purple-500 mr-2"></i>短语查询
                    </h3>
                    <p>倒排索引可以保存词的位置，因此可以支持短语查询。短语查询要求词按特定顺序出现在文档中。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover border-t-4 border-yellow-500">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-sliders-h text-yellow-500 mr-2"></i>近似搜索
                    </h3>
                    <p>通过记录词的位置，倒排索引可以实现近似搜索，即词汇在文档中的相对位置接近的查询。</p>
                </div>
            </div>
        </section>

        <!-- Optimization Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-lg bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-tachometer-alt text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">优化倒排索引的策略</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-compress-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">压缩</h3>
                    <p class="text-gray-700">使用压缩算法（如前缀压缩）来减少索引的大小，提高内存和磁盘的使用效率。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-object-group"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">分段合并</h3>
                    <p class="text-gray-700">定期将小的索引段合并成更大的段，减少磁盘寻道时间和查询延迟。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md transition duration-300 card-hover">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-list-ul"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">跳表结构</h3>
                    <p class="text-gray-700">在长的倒排列表中使用跳表结构，能够快速跳过不相关的部分，提高查询速度。</p>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition duration-300 link-hover inline-block">
                    <i class="fas fa-globe mr-2"></i>www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```